import { store } from '@/utils/store'
import { call } from '@/utils/request'
App({
  // 冷启动时会执行，只会加载一次
  onLaunch() {
    wx.cloud.init({
      env: 'prod-7gk926fb556e9aad',
      // traceUser: true,
    })

    // 获取初始化数据
    this.getInitData()
    wx.onNetworkStatusChange(res => {
      if (res.isConnected) {
        this.getInitData()
      }
    })

    // 获取小程序系统信息
    store.set_window_info()
  },
  getInitData() {
    this.getUserInfo()
    this.getConfig()
  },
  getUserInfo() {
    call('/getUserInfo').then(res=>store.set_user_info(res, true))
  },
  getConfig() {
    call('/getConfig').then(res=>store.set_config(res))
  }
})
